const express = require('express');
const router = express.Router();
const db = require('../../utils/db');

// 调价统计
router.post('/AdjustPriceGet',(req,res)=>{
    const {page, pageSize,date,name}=req.body;
      let  sql=`SELECT * FROM medicinal_information  LEFT JOIN detail_price ON detail_price.d_m_id=medicinal_information.m_id LEFT JOIN doctor ON detail_price.d_u_id=doctor.u_id WHERE d_createTime LIKE '%${date}%' AND m_name LIKE '%${name}%'  LIMIT ${(page - 1)* pageSize},${pageSize}`;
      let  sql1=`SELECT COUNT(*) AS total FROM medicinal_information  LEFT JOIN detail_price ON detail_price.d_m_id=medicinal_information.m_id LEFT JOIN doctor ON detail_price.d_u_id=doctor.u_id WHERE d_createTime LIKE '%${date}%' `;
    db.query(sql,(err,data)=>{
    if(err){
        res.send({ error: 1, msg: err });
    }else{
        db.query(sql1,(err2,data2)=>{
            if(err2){
                res.send({ error: 1, msg: err2 });
            }else{
                res.send({ error: 0, data: data, total: data2[0].total });
            }  
        })
    }
    })
})

module.exports = router